﻿#include <iostream>
#include <string>
#include <set>

int main() {
    std::set<std::string> brackets = { "()", "[]", "{}", "<>" };
    std::string v;
    std::cout << "Введите последовательность:";
    std::cin >> v;

    // Remove all spaces from the input string
    v.erase(remove(v.begin(), v.end(), ' '), v.end());

    for (size_t i = 0; i < v.length() / 2; ++i) {
        for (const auto& pair : brackets) {
            // Find the bracket pair in the string and erase it
            size_t pos;
            while ((pos = v.find(pair)) != std::string::npos) {
                v.erase(pos, 2);
            }
        }
    }

    if (v.empty()) {
        std::cout << "TRUE" << std::endl;
    }
    else {
        std::cout << "FALSE" << std::endl;
    }

    return 0;
}

